import Vue from 'vue';
import Vuex from 'vuex';


//全局使用Vuex这个插件
Vue.use(Vuex);

//定义一个store对象
const store =new Vuex.Store({
    //定义要存放的数据
    state:{
        token:null,
        UserName:'',
        token:localStorage.getItem('saveToken'),
        saveExpires:localStorage.getItem('saveExpires'),
        RefreshExpires:null
    },
    mutations:{
        set_Name(state,name){ 
            state.UserName=name;
        },
        saveToken(state, data) {
            state.token = data;
        },
        saveExpires(state,data)
        {
            state.saveExpires=data;
        },
        saveRefreshExpires(state,data)
        {
            state.RefreshExpires=data;
        },
    },
});
export default store;//到处Store对象